import type { App } from 'vue'
import { defineAsyncComponent } from 'vue'

export default {
  install: (app: App) => {
    const modules: any = import.meta.glob('./**/*.vue')

    for (const [key, value] of Object.entries(modules)) {
      const str: any = value
      const arr = key.split('/')
      const name = arr[arr.length - 1].split('.')[0]
      app.component(name, defineAsyncComponent(str))
    }
  }
}
